package com.gf.framework.cruddemo.controller;

import com.gf.framework.cruddemo.entity.Student;
import com.gf.framework.cruddemo.mapper.StudentMapper;
import com.gf.framework.cruddemo.service.impl.StudentServiceImpl;
import com.gf.framework.mysql.controller.MysqlCrudController;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @author gaofei
 * @date 2022/5/22 22:16
 */
@Api(tags = "学生操作")
@RequestMapping("student")
@RestController
@Slf4j
public class StudentController extends MysqlCrudController<Student, StudentMapper, StudentServiceImpl> {
    @Override
    protected boolean autoId() {
        return false;
    }

    @GetMapping("cachetest")
    @Transactional
    public Boolean cachetest() throws InterruptedException {
        for (int i = 0; i < 100; i++) {
            log.info(queryById(5L).toString());
            TimeUnit.SECONDS.sleep(1);
        }
        return true;
    }
}
